

package com.example.tests;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;

import java.util.List;

import org.junit.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
import com.example.fw.ContactObject;
import com.example.fw.Groups;


public class ContactRemovalTests extends TestBase{

	@Test
	public void testContactCanBeDeleted() throws Exception {
		String deletedContactId = app.getContactHelper().deleteContact(0);
	//	Set<ContactObject> newContactList = app.getContactHelper().getContacts();
		List<ContactObject> newContactList = app.getHibernateHelper().getContacts();
	
		boolean isDeletedFound = false;
		for (ContactObject currentContat : newContactList){
			if (currentContat.id.compareTo(deletedContactId) == 0){
				isDeletedFound = true;
				break;
			}
		}
		Assert.assertFalse("Group is not deleted", isDeletedFound);
		
	}
	
	@AfterMethod
	public void testUIConformsWithDB(){
		if (app.getProperty("uiDb.check") != null){
			Groups dbList = app.getHibernateHelper().getGroups();
			Groups uiList = app.getGroupHelper().getUiGroups();
			assertThat(uiList, equalTo(dbList));
		}
		
	}
}
